﻿<html>
	<body>
		<?php
			
			session_start();
			if (isset($_POST['user'])){
				$user = $_POST['user'];
			}else{
				$user = "";
			}
			if (isset($_POST['pass'])){
				$pass = $_POST['pass'];
			}else{
				$pass = "";
			}
			echo "$user    $pass";
			require('php/connexionBaseDeDonnees.php');
			
			//$reponses = $bd->prepare("Update client set Password = :pass where matricule = :user");
			//$reponses = $reponses->execute(array(':pass' => MD5($pass), ':user' => $user));

			$sql = "Select * from client where matricule = '".$user."' and password = '".MD5($pass)."'";
			echo "Select * from client where matricule = '".$user."' and password = '".MD5($pass)."'";
			$reponse = $bd->query($sql);
			$result = $reponse->fetch();
			$url=$_SESSION['url'];
			if ($result['nom']<>"") {
				$_SESSION['user'] = $user;
				$_SESSION['NOM'] = $result['prenom']." ".$result['nom'];
				$_SESSION['mode'] = $result['mode'];
			}else{
				if (ini_get("session.use_cookies")) {
					$params = session_get_cookie_params();
					setcookie(session_name(), '', time() - 42000,
						$params["path"], $params["domain"],
						$params["secure"], $params["httponly"]
						);
				}
				$_SESSION = array();
				session_unset();
				session_destroy();
			}
			header("Location: ".$url);
		?>
	</body>
</html>


<!--

$reponses = $bd->prepare("Update client set Password = :pass where nom = 'Tracer'");
$reponses = $reponses->execute(array(':pass' => MD5('')));
if($reponses){
	echo "FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU";
}

-->